#include <vector>
#include <set>
#include <iostream>
#include <unordered_map>
#include <numeric>

using namespace std;

string reverseWords(string s) {
    int pre = 0, next = 0;
    while(next < s.size()){
        next++;
        if(next == s.size() || s[next] == 32){
            reverse(s.begin() + pre, s.begin() + next);
            pre = ++next;
        }
    }
    return s;
}

int main(){
    string s = "Let's take LeetCode contest";
    string ret = reverseWords(s);
    for(char s : ret){
        cout << s;
    }
    cout << endl;
    return 0;
}